package com.jtbd.service.campus;

import com.jtbd.constants.ResponseCodeEnum;
import com.jtbd.domain.CourseStudentRelation;
import com.jtbd.exceptions.SystemException;
import com.jtbd.mapper.CourseStudentRelationMapper;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

/**
 * 处理课程学生关系
 */
@Service
public class CourseStudentRelationService {
    @Resource
    private CourseStudentRelationMapper courseStudentRelationMapper;

    /**
     * 添加课程学生关系
     *
     * @param courseStudentRelation 课程学生关系信息
     * @return 新增的课程学生关系ID
     */
    public Long addCourseStudentRelation(CourseStudentRelation courseStudentRelation) {
        int insertResult = courseStudentRelationMapper.insert(courseStudentRelation);
        if (insertResult > 0) {
            return courseStudentRelation.getId();
        }
        throw new SystemException(ResponseCodeEnum.ERROR.getCode(), "添加课程学生关系失败");
    }
}
